#!/usr/bin/env python
# -*- coding:utf-8 -*-

import os
import configparser

class Config:
    @staticmethod
    def get_config():
        """
        读取配置文件
        """
        config = configparser.ConfigParser()
        config.read('config/develop_config.conf', encoding='utf-8')
        return config

    @staticmethod
    def get_jwt_config():
        """
        获取JWT相关配置
        """
        config = Config.get_config()
        return {
            'secret_key': config.get('JWT', 'secret_key'),
            'token_expires': config.getint('BASIC', 'token_expires', fallback=3600)
        }

    @staticmethod
    def get_db_config():
        """
        获取数据库配置
        """
        config = Config.get_config()
        return {
            'dialect': config.get('DATABASE', 'dialect'),
            'driver': config.get('DATABASE', 'driver'),
            'username': config.get('DATABASE', 'username'),
            'password': config.get('DATABASE', 'password'),
            'host': config.get('DATABASE', 'host'),
            'port': config.get('DATABASE', 'port'),
            'database': config.get('DATABASE', 'database')
        } 